package cn.tedu.jdbc;

import java.sql.*;
import java.util.Arrays;

public class Test02 {
    public static void main(String[] args) throws Exception {
        Class.forName("com.mysql.jdbc.Driver");
        String url="jdbc:mysql:///cgb2107?characterEncoding=utf8";
        Connection conn = DriverManager.getConnection(url, "root", "root");
        Statement st = conn.createStatement();
        ResultSet rs = st.executeQuery("select * from emp");
        while (rs.next()){
//            int a=rs.getInt(1);
////            String as=rs.getString("ename");
////            System.out.println(a+"|"+as);
            for (int i = 1; i <=8 ; i++) {
               String as=rs.getString(i);
                System.out.println(as);
            }
        }



        rs.close();
        st.close();
        conn.close();
        as();
    }
    public static void as() throws Exception {
        Class.forName("com.mysql.jdbc.Driver");
        String url="jdbc:mysql:///cgb2107?characterEncoding=utf8";
        Connection conn = DriverManager.getConnection(url, "root", "root");
        Statement st = conn.createStatement();
        st.executeUpdate("insert into emp ('ename','job') values ('sdj','siod')");
        st.close();
        conn.close();
        }

    }

